package com.shop.admin.dao.pink;

import com.shop.jpa.BaseDao;
import com.shop.domain.pink.SnapRedPink;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.math.BigDecimal;
import java.util.List;

@Repository
public interface SnapRedPinkDao extends BaseDao<SnapRedPink, Long> {

    @Modifying(clearAutomatically = true)
    @Query(value = "insert into t_snap_red_pink(pink_id,uid,order_no,red_amount) value(?1,?2,?3,?4)",nativeQuery = true)
    int addAutoPinkByZj(Long pink_id, Long uid, String order_no, BigDecimal red_amount);


    @Query(nativeQuery = true,value = "select p.* from t_snap_red_pink p where p.is_settlement = 0 order by id asc limit ?1")
    List<SnapRedPink> findNeedSettlement(int limit);

}
